package com.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * 大学 ： 要管理学院college
 */
public class University extends OrganizationComponent{

    List<OrganizationComponent> colleges =  new ArrayList<>();

    //构造器
    public University(String name, String des) {
        super(name, des);
    }

    //这里实际传入的应当是一个 学院对象
    @Override
    protected void add(OrganizationComponent organizationComponent) {
        colleges.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        colleges.remove(organizationComponent);
    }

    //输出University中包含的学院
    @Override
    protected void print() {
        System.out.println("----------"+getName()+"--------");
        colleges.forEach(OrganizationComponent::print);
    }
}
